//
//  ShopGoodInfoOneTableViewCell.m
//  BaseFrame
//
//  Created by 吕金状 on 2017/6/28.
//  Copyright © 2017年 com.mxh. All rights reserved.
//

#import "ShopGoodInfoOneTableViewCell.h"
@interface ShopGoodInfoOneTableViewCell()<UITextFieldDelegate>

@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) UITextField *textField;
@property (nonatomic,strong) UIView *shapeView;
Strong UILabel *contentLabel;

@end

@implementation ShopGoodInfoOneTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = 0;
        
        _shapeView = [UIView new];
        _shapeView.backgroundColor = getColor(mainColor);
        _shapeView.layer.masksToBounds = YES;
        _shapeView.layer.cornerRadius = 1;
        
        _titleLabel = [UILabel new];
        _titleLabel.font = [UIFont systemFontOfSize:15 weight:1];
        
        _textField = [UITextField new];
        _textField.font = DEF_FontSize_15;
        _textField.delegate = self;
        
        _contentLabel  = [[UILabel alloc]init];
        _contentLabel.font = DEF_FontSize_14;
        [self.contentView addSubview:_contentLabel];
        
        [self.contentView addSubview:_titleLabel];
        [self.contentView addSubview:_textField];
        [self.contentView addSubview:_shapeView];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    _shapeView.frame = CGRectMake(55, 12, 5, self.height-24);
    _titleLabel.frame = CGRectMake(CGRectGetMaxX(_shapeView.frame) + 5, 0, 85, self.height);
    _textField.frame = CGRectMake(CGRectGetMaxX(_titleLabel.frame), 0, SCREEN_WIDTH - CGRectGetMaxX(_titleLabel.frame), self.height);
    _contentLabel.frame = CGRectMake(CGRectGetMaxX(_titleLabel.frame), 0, SCREEN_WIDTH - CGRectGetMaxX(_titleLabel.frame), self.height);
}

- (void)setDataDictionary:(NSDictionary *)dataDictionary{
    _dataDictionary = dataDictionary;
    _titleLabel.text = _dataDictionary[@"title"];
    _textField.placeholder = _dataDictionary[@"ph"];
    _textField.text = [NSString stringWithFormat:@"%@",_dataDictionary[@"key"]];
}

#pragma mark - UITextFieldDelegate

- (void)textFieldDidEndEditing:(UITextField *)textField{
    if (_getTextFieldClick) {
        _getTextFieldClick(textField.text);
    }
}

@end
